package prolog.fluents
import prolog.terms.Int
import prolog.terms.Prog
import prolog.terms.Source
import prolog.terms.Term

/* Create a source of integers based on x=a*x+b formula */

  
class  IntegerSource(var fuel:Long,var a:Long,var x:Long,var b:Long,p:Prog) extends Source
	{
		def this(fuel:Long,a:Long,x:Long,b:Long,p:Prog)=this(fuel,a,x,b,p)

		def getElement():Int={
					if(fuel<0){ 
					  Unit}
					var R:Int=Int(x)
					x=a*x+b
					fuel-=fuel
					R
				       }

		def stop():Unit={
				fuel=0
				}

		def toString():String={
				      "{(x->"+a+"*x+"+b+")["+fuel+"]="+x+"}"
				       }
 	}	
